package com.dhcc.DRGsHosp.application.impl;

import java.io.Serializable;
import java.util.List;
import java.util.Set;

import javax.inject.Named;

import org.dayatang.domain.EntityRepository;
import org.dayatang.domain.InstanceFactory;
import org.springframework.transaction.annotation.Transactional;

import com.dhcc.DRGsHosp.application.GroupingLogApplication;
import com.dhcc.DRGsHosp.core.domain.GroupingLog;

@Named
@Transactional
public class GroupingLogApplicationImpl implements GroupingLogApplication,Serializable {
	private static final long serialVersionUID = 1L;
	private EntityRepository repository;
    
    private EntityRepository getRepository() {
		if (repository == null) {
			repository = InstanceFactory.getInstance(
					EntityRepository.class, "repository");
		}
		return repository;
	}

	public GroupingLog getGroupingLog(String id) {
		return GroupingLog.get(GroupingLog.class, id);
	}
	
	public void creatGroupingLog(GroupingLog groupingLog) {
		groupingLog.save();
	}
	
	public void updateGroupingLog(GroupingLog groupingLog) {
		groupingLog .save();
	}
	
	public void removeGroupingLog(GroupingLog groupingLog) {
		if(groupingLog != null){
			groupingLog.remove();
		}
	}
	
	public void removeGroupingLogs(Set<GroupingLog> groupingLogs) {
		for (GroupingLog groupingLog : groupingLogs) {
			groupingLog.remove();
		}
	}
	
	public List<GroupingLog> findAllGroupingLog() {
		return GroupingLog.findAll(GroupingLog.class);
	}
}
